#include <stdio.h>

int power(int x, int n)
{
    int ret = 1;

    while (n) {
        if (n&1)
            ret *= x;
        x *= x;
        n >>= 1;
    }

    return ret;
}

int getlength(int x)
{
    int len = 1;

    while ((x = x/10) != 0) {
        len ++;
    }

    return len;
}

int main(int argc, char *argv[])
{
    int i, j, n, sum, tmp;

    for (i = 100; i <= 99999; i++) {
        n = getlength(i);

        tmp = i, sum = 0;
        for (j = 0; j < n; j++) {
            sum += power(tmp%10, n);
            tmp = tmp/10;
        }

        if (sum == i)
            printf("%d ", i);
    }
    printf("\n");

    return 0;
}
